<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手机号输入页面</title>
    <style>
        body {
            background: linear-gradient(45deg, #ff7e5f, #feb47b); /* 酷炫的渐变背景 */
            height: 100vh;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: Arial, sans-serif;
        }
        .container {
            text-align: center;
            animation: fadeIn 2s ease-in-out; /* 添加淡入动画 */
        }
        .art-text {
            font-size: 2rem;
            font-weight: bold;
            color: #fff;
            margin-bottom: 20px;
            text-shadow: 2px 2px 4px #000000;
        }
        input[type="text"] {
            width: 300px;
            height: 40px;
            font-size: 1rem;
            padding: 5px;
            margin-bottom: 10px;
            border-radius: 10px; /* 输入框圆角 */
            border: 2px solid #ccc;
            transition: border-color 0.3s ease; /* 输入框边框颜色过渡动画 */
        }
        input[type="text"]:focus {
            border-color: #4caf50; /* 输入框获取焦点时边框颜色 */
        }
        .confirm-btn {
            background-color: #4caf50; /* 绿色按钮 */
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            font-size: 1rem;
            cursor: pointer;
            transition: background-color 0.3s ease; /* 按钮背景颜色过渡动画 */
        }
        .confirm-btn:hover {
            background-color: #45a049;
        }
        .service-type {
            display: inline-block;
            margin: 10px;
            padding: 10px 20px;
            border: 2px solid #ccc;
            border-radius: 5px;
            background-color: #f9f9f9;
            cursor: pointer;
            transition: background-color 0.3s ease, border-color 0.3s ease;
            position: relative; /* 用于绝对定位勾选图标 */
        }
        .service-type:hover {
            background-color: #e9e9e9;
        }
        .service-type input[type="radio"] {
            display: none; /* 隐藏原生单选按钮 */
        }
        .service-type label {
            display: block;
            width: 100%;
            height: 100%;
            box-sizing: border-box;
        }
        .service-type input[type="radio"]:checked + label {
            background-color: #4caf50; /* 勾选后背景颜色 */
            color: white;
        }
        .service-type input[type="radio"]:checked + label::before {
            content: "✓";
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 1.5rem;
            color: white;
        }
        /* 淡入动画 */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px); /* 从下往上淡入 */
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="art-text">请选择您要购买的服务类型：</div>
    <div class="service-type" onclick="toggleSelection('docker')">
        <input type="radio" id="docker" name="serviceType" value="docker">
        <label for="docker">Docker</label>
    </div>
    <div class="service-type" onclick="toggleSelection('k8s')">
        <input type="radio" id="k8s" name="serviceType" value="k8s">
        <label for="k8s">Kubernetes (K8s)</label>
    </div>
    <div class="art-text">请输入你的手机号</div>
    <input type="text" id="phoneInput" placeholder="手机号" />
    <button class="confirm-btn" onclick="sendPhoneNumber()">确认</button>
</div>

<script>
    function toggleSelection(id) {
        const input = document.getElementById(id);
        const allInputs = document.querySelectorAll('input[name="serviceType"]');

        if (input.checked) {
            // 如果当前已选中，取消选中
            input.checked = false;
        } else {
            // 如果当前未选中，取消其他所有选项的选中状态，并选中当前项
            allInputs.forEach(inp => inp.checked = false);
            input.checked = true;
        }
    }

    function sendPhoneNumber() {
        var phoneNumber = document.getElementById('phoneInput').value;
        var serviceType = document.querySelector('input[name="serviceType"]:checked');

        if (!phoneNumber) {
            alert("请输入手机号！");
            return;
        }
        if (!serviceType) {
            alert("请选择服务类型！");
            return;
        }

        baseurl = "http://127.0.0.1:8080/qrcode/submitPhone?"
        console.log(phoneNumber,serviceType.value)
        window.location.href = baseurl + "phone=" + encodeURIComponent(phoneNumber) + "&service=" + encodeURIComponent(serviceType.value);
    }
</script>
</body>
</html>